package util

import (
	"crypto/md5"
	"encoding/hex"
	"github.com/kataras/iris/v12"
	"strconv"
)

// MD5加密字符串
func MD5(text string) string {
	ctx := md5.New()
	ctx.Write([]byte(text))
	return hex.EncodeToString(ctx.Sum(nil))
}


// 解析分页数据:
func ParserPageCount(ctx iris.Context) (int, int, bool) {
	l := ctx.URLParam("limit")
	o := ctx.URLParam("offset")
	if l == ""{
		l = "10"
	}
	if o == ""{
		o = "0"
	}
	limit, err := strconv.Atoi(l)
	offset, err := strconv.Atoi(o)
	if err != nil {
		return 0, 0, false
	}
	return limit, offset, true
}